<template>
    <div id='' class='font_app'>
        <Header :bgColor="bgColor" :logoImg="logoImg" @layout="layoutSys" @backHome="backHome" @changePassword="changePassword" />
        <!-- <keep-alive :include="keepAlive"> -->
        <router-view />
        <!-- </keep-alive> -->
        <ChangePassword ref="changePassword" @backLogin="backLogin" />
    </div>
</template>
<script>
import Header from '@/pages/fontApp/header.vue'
import ChangePassword from '@/pages/fontApp/changepassword.vue';
import headerLogo from '@/assets/svg/fontApp/header_logo.svg'
import { mapState, mapActions } from 'vuex';
export default {
    name: '',
    props: [''],
    data() {
        return {
            keepAlive: [],
        };
    },
    components: { Header, ChangePassword },
    computed: {
        ...mapState('extend/header', ['bgColor', 'logoImg']),
        ...mapState('admin/layout', [
            'isMobile',
            'logoutConfirm'
        ])
    },
    beforeMount() { },
    mounted() {
        if (window.history && window.history.pushState) {
            history.pushState(null, null, document.URL)
            window.addEventListener('popstate', this.goBack, false)
        }
    },
    methods: {
        ...mapActions('admin/account', [
            'logout'
        ]),
        ...mapActions('extend/header', [
            'changeHeader'
        ]),
        layoutSys() {
            this.logout({
                confirm: this.logoutConfirm,
                vm: this
            });
        },
        backHome() {
            this.changeHeader([
                { key: 'bgColor', value: 'rgba(0, 0, 0, 0.03)' },
                { key: 'logoImg', value: headerLogo },
            ])
            this.$router.replace('/center/fontApp', () => { })
        },
        goBack() {
            this.changeHeader([
                { key: 'bgColor', value: 'rgba(0, 0, 0, 0.03)' },
                { key: 'logoImg', value: headerLogo },
            ])
        },
        //修改密码
        changePassword() {
            this.$refs.changePassword.init()
        },
        //修改密码成功后-返回重新登录
        backLogin() {
            this.logout();
        }
    },
    destroyed() {
        window.removeEventListener('popstate', this.goBack, false)
    },
    watch: {}
}
</script>
<style lang='less' scoped>
.font_app {
    position: relative;
}
</style>